package 面试;

public class Singleton {
    private volatile Singleton singleton;
    public Singleton(){}


    public Singleton getSingleton() {
        if(singleton==null){
            synchronized (this){
                if(singleton==null){
                    singleton=new Singleton();
                }
            }
        }
        return singleton;

    }
}
